home *** CD-ROM | disk | FTP | other *** search
- Path: geraldo.cc.utexas.edu!usenet
- From: wharris@mail.utexas.edu (W. Harris)
- Newsgroups: comp.lang.c++
- Subject: problem writing class to a file..... - temp.txt [1/1]
- Date: 5 Feb 1996 16:10:22 GMT
- Organization: The University of Texas at Austin
- Message-ID: <4f5a5e$3ca@geraldo.cc.utexas.edu>
- NNTP-Posting-Host: slip-41-11.ots.utexas.edu
- Mime-Version: 1.0
- Content-Type: Text/Plain
- X-Newsreader: WinVN 0.90.4
-
-
- The problem I'm having is in the code "outfile.write(char *)&.....".
- The book I used to learn C, C++ indicates this should work. The
- compiler error I'm getting is "sizeof cannot be used on a
- function". Code has been reduced; the struct definition and the
- constructor have been left out. I've also opened the file for binary
- output. (not indicated in code)
-
-
-
- class CarData
- {
- private :
-
- char VIN[7],Stock[7],Tag[7],Tech[4],Color[12],Model[16],Year[5];
- char EstAmt[6],Name[35],Address[32],City[19],State[3],Zip[6];
- char Area[4],Prefix[4],Num[5],WArea[4],WPrefix[4],WNum[5];
- char FnlAmt[6];
-
- public :
-
- CarData(struct astruct1 CarInf);
- };
- //*********************************************************************
-
-
- void main()
- {
-
-
- CarData CarConst1(struct astruct1 CarInfo); //1st instance of cnstctr
- outfile.write((char *)&CarConst1, sizeof(CarConst1)); //*****ERROR IS OCCURRING HERE*
- getch();
- closegraph();
- }
-
- //*******************************************************************
-
-
-